home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
clickb1r
/
printmai.bas
< prev
next >
Wrap
BASIC Source File
|
1999-07-21
|
15KB
|
334 lines
Attribute VB_Name = "Module1"
Dim strdata As String 'variable for included/excluded words
Dim base64 As String
Dim counter As Integer 'counts through included/excluded words
Dim filenam As String 'filename of file to extract
Dim firstline As String 'each line of .eml file
Dim appath As String 'application & .eml file path
Private Function Base64Decode(Basein As String) As String
Dim counter As Integer
Dim Temp As String
'For the dec. Tab
Dim DecodeTable As Variant
Dim Out(2) As Byte
Dim inp(3) As Byte
'DecodeTable holds the decode tab
DecodeTable = Array("255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "62", "255", "255", "255", "63", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "255", "255", "255", "64", "255", "255", "255", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", _
"18", "19", "20", "21", "22", "23", "24", "25", "255", "255", "255", "255", "255", "255", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255" _
, "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255", "255")
'Reads 4 Bytes in and decrypt them
For counter = 1 To Len(Basein) Step 4
'4 Bytes in -> 3 Bytes out
inp(0) = DecodeTable(Asc(Mid$(Basein, counter, 1)))
inp(1) = DecodeTable(Asc(Mid$(Basein, counter + 1, 1)))
inp(2) = DecodeTable(Asc(Mid$(Basein, counter + 2, 1)))
inp(3) = DecodeTable(Asc(Mid$(Basein, counter + 3, 1)))
Out(0) = (inp(0) * 4) Or ((inp(1) \ 16) And &H3)
Out(1) = ((inp(1) And &HF) * 16) Or ((inp(2) \ 4) And &HF)
Out(2) = ((inp(2) And &H3) * 64) Or inp(3)
'* look for "=" symbols
If inp(2) = 64 Then
'If there are 2 characters left -> 1 binary out
Out(0) = (inp(0) * 4) Or ((inp(1) \ 16) And &H3)
Temp = Temp & Chr(Out(0) And &HFF)
ElseIf inp(3) = 64 Then
'If there are 3 characters left -> 2 binaries out
Out(0) = (inp(0) * 4) Or ((inp(1) \ 16) And &H3)
Out(1) = ((inp(1) And &HF) * 16) Or ((inp(2) \ 4) And &HF)
Temp = Temp & Chr(Out(0) And &HFF) & Chr(Out(1) And &HFF)
Else 'Return three Bytes
Temp = Temp & Chr(Out(0) And &HFF) & Chr(Out(1) And &HFF) & Chr(Out(2) And &HFF)
End If
Next
Base64Decode = Temp
End Function
Private Sub decode()
'filenam = Mid(firstline, 8, Len(firstline) - 8) 'get filename of file to extract
'Line Input #2, firstline
If filenam = "" Then
decodeimbed64
ElseIf base64 = "base64" Then
decode64
ElseIf Right(filenam, 4) = ".rtf" Then
decodeRTF
ElseIf Right(filenam, 4) = ".txt" Then
decodeTXT
Else
Print #1,
Print #1, Chr(9) + "file: " + filenam + " NOT extracted"
Do While Not EOF(2)
Line Input #2, firstline
Do Until strdata = "EndofData" 'repeat until all invalid words checked
getbadwords ' get next invalid word
If InStr(firstline, strdata) Then Exit Do 'if line includes invalid word then exit loop
Loop ' round again for next invalid word
If strdata <> "EndofData" Then Exit Do
Loop
strdata = "NextPart"
Exit Sub
End If
Close #3
Print #1,
Print #1, Chr(9) + "file: " + filenam + " extracted"
strdata = "NextPart"
filenam = ""
base64 = ""
End Sub
Private Sub decode64()
Dim bin64 As String
Open appath + "\" + filenam For Output As #3 'open file to extract to
While Trim(firstline) <> "" 'get rid of blank lines
Line Input #2, firstline
Wend
While InStr(firstline, "NextPart") = Not True 'till end of data
Line Input #2, firstline
If (Len(firstline) Mod 4) = 0 Then 'line must be a multiple of 4
bin64 = Base64Decode(firstline) 'call decoder
Print #3, bin64; 'print decoded data to file
Else
Exit Sub
End If
Wend
End Sub
Private Sub decodeimbed64()
Dim bin64 As String
While Trim(firstline) <> "" 'get rid of blank lines
Line Input #2, firstline
Wend
While InStr(firstline, "NextPart") = Not True 'till end of data
Line Input #2, firstline
If (Len(firstline) Mod 4) = 0 Then 'line must be a multiple of 4
bin64 = Base64Decode(firstline) 'call decoder
Print #1, bin64; 'print decoded data to file
Else
Exit Sub
End If
Wend
End Sub
Private Sub decodeRTF()
Open appath + "\" + filenam For Output As #3 'open file to extract to
While Trim(firstline) <> "" 'get rid of blank lines
Line Input #2, firstline
Wend
While InStr(firstline, "NextPart") = Not True 'till end of data
Line Input #2, firstline
If Right(firstline, 1) = "=" Then
Print #3, Left(firstline, Len(firstline) - 1);
ElseIf Len(firstline) < 3 Then
Print #3, firstline
ElseIf Len(firstline) > 2 And Mid(firstline, Len(firstline) - 2, 1) = "=" Then
Print #3, Left(firstline, Len(firstline) - 3);
ElseIf InStr(firstline, "NextPart") = Not True Then
Print #3, firstline
End If
Wend
End Sub
Private Sub decodeTXT()
Open appath + "\" + filenam For Output As #3 'open file to extract to
While Trim(firstline) <> "" 'get rid of blank lines
Line Input #2, firstline
Wend
While InStr(firstline, "NextPart") = Not True 'till end of data
Line Input #2, firstline
If InStr(firstline, "NextPart") = Not True Then
If Right(firstline, 1) = "=" Then
Print #3, Left(firstline, Len(firstline) - 1)
Else
Print #3, firstline
End If
End If
Wend
End Sub
Private Sub Main()
Dim nextfile As String 'filename of .eml file
Dim lastline As String 'checks multiple blank lines
Dim filenum As Integer 'counts messages
appath = App.Path 'sets path
nextfile = Dir(appath + "\*.eml") 'gets first .eml filename
strdata = "" 'initialises variable
'HEADER SECTION
If nextfile <> "" Then
Open appath + "\EHCNet3.tmp" For Output As #1 'if .eml file present open text file for writing
Open appath + "\EHCNet3.txt" For Output As #4 'if .eml file present open index file for writing
form1.Visible = True
form1.Refresh
End If
Print #1,
Prin